package com.limao.Tool;

import java.util.HashMap;
import java.util.Set;

import com.cloopen.rest.sdk.CCPRestSDK;

public class SMSCloopen {
	
	//云通讯
	public static boolean send(String mobile, String code) {
		HashMap<String, Object> result = null;

		CCPRestSDK restAPI = new CCPRestSDK();
		restAPI.init("app.cloopen.com", "8883");// 初始化服务器地址和端口
		restAPI.setAccount("8a48b5514700da2f014718c75d2d05d8",
				"218410bcf27c4fc3b47c847bad49d6d0");// 初始化主帐号名称和主帐号令牌
		restAPI.setAppId("8a48b5514700da2f014718e0f78005e4");// 初始化应用ID
		result = restAPI.sendTemplateSMS(mobile, "2265", new String[] { code });

		System.out.println("SDKTestGetSubAccounts result=" + result);
		if ("000000".equals(result.get("statusCode"))) {
			//正常返回输出data包体信息（map）
			@SuppressWarnings("unchecked")
			HashMap<String, Object> data = (HashMap<String, Object>) result.get("data");
			Set<String> keySet = data.keySet();
			for (String key : keySet) {
				Object object = data.get(key);
				System.out.println(key + " = " + object);
			}
		} else {
			//异常返回输出错误码和错误信息
			System.out.println("错误码=" + result.get("statusCode") + " 错误信息= "
					+ result.get("statusMsg"));
			return false;

		}
		return true;
	}
}
